package com.share.framework.init.shenyu;

import com.share.framework.common.config.shenyu.other.ShenyuClientRegisterRepository;
import com.share.framework.common.config.shenyu.properties.PropertiesConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Controller;

import java.util.Properties;

public class SpringMvcClientBeanPostProcessor implements BeanPostProcessor {
    private static final Logger LOG = LoggerFactory.getLogger(SpringMvcClientBeanPostProcessor.class);
    public SpringMvcClientBeanPostProcessor(final PropertiesConfig clientConfig,
                                            final ShenyuClientRegisterRepository shenyuClientRegisterRepository) {
        Properties props = clientConfig.getProps();
    }

    @Override
    public Object postProcessAfterInitialization(@NonNull final Object bean, @NonNull final String beanName) throws BeansException {
        // Filter out is not controller out
        Controller annotation = AnnotationUtils.findAnnotation(bean.getClass(), Controller.class);
        if (annotation != null) {
            LOG.info("发现Controller {}", bean.getClass());
        }

        return bean;
    }
}
